package com.example.fsd.controller.jdal;

import com.example.fsd.common.result.R;
import com.example.fsd.pojo.Jdal;
import com.example.fsd.service.configs.IConfigsService;
import com.example.fsd.service.jdal.IJdalService;
import com.example.fsd.vo.PageVo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhangguihong
 * @since 2024-11-22
 */
@RestController
@RequestMapping("/jdal")
@RequiredArgsConstructor
public class JdalController {
    private final IJdalService jdalService;

    @GetMapping("/listjdalPage")
    private R listjdalPage(PageVo pageVo) {
        return jdalService.listjdalPage(pageVo);
    }

    @GetMapping("/findjdalById/{id}")
    private R findjdalById(@PathVariable Integer id) {
        return jdalService.findjdalById(id);
    }

    @GetMapping("/findjdalnextById/{id}")
    private R findjdalnextById(@PathVariable Integer id) {
        return jdalService.findjdalnextById(id);
    }

    @GetMapping("/findjdalprevById/{id}")
    private R findjdalprevById(@PathVariable Integer id) {
        return jdalService.findjdalprevById(id);
    }

    @GetMapping("/findAllJdal")
    private R findAllJdal() {
        return jdalService.findAlljdal();
    }

    @PostMapping("handleImage")
    private R handleImage(@RequestParam("file") MultipartFile file) {
        return jdalService.handleImage(file);
    }

    @PostMapping("/addJdal")
    private R addJdal(@RequestBody Jdal jdal) {
        return jdalService.addJdal(jdal);
    }

    @PostMapping("/updateCasexqImg")
    private R updateCasexqImg(MultipartFile file, Integer id) {
        return jdalService.updateCasexqImg(file, id);
    }

    @PutMapping("/updateJdal")
    private R updateJdal(@RequestBody Jdal jdal) {
        return jdalService.updateJdal(jdal);
    }
}
